package visualcbir.principal;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import visualcbir.visualstructures.VSGrid;

/**
 *
 * @author sheila
 */
public class PnlVSChoose extends JPanel {
    private  JTextField txtNumLevels;
    private String strVisualStructures[];
    private List<JComboBox> cmbs;

    public PnlVSChoose() {
        initComponents();
    }

    public void initComponents(){
        JLabel lblNumLevels = new JLabel("Número Nívels");
        txtNumLevels = new JTextField();
        JButton btnShow = new JButton("Mostrar opções de níveis");

        final JButton btnProcess = new JButton("Criar estrutura");

        btnShow.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                createOptions();
                PnlVSChoose.this.add(btnProcess);
            }
        });
        btnProcess.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                for (JComboBox cmb : cmbs) {
                    String strStructure = String.valueOf( cmb.getSelectedItem());
                   // getStructure(strStructure);
                }
            }
        });


        this.add(lblNumLevels);
        this.add(txtNumLevels);
        this.add(btnShow);
    }

    public void createOptions(){
        for (int i=0 ; i < Integer.parseInt(txtNumLevels.getText()) ; i++) {
            JComboBox cmb = createStructureOptions();
            cmbs.add(cmb);
            this.add(cmb);
        }
    }

    public JComboBox createStructureOptions(){
        String[] strStructures = { "Grid","Circle", "Concentric Rings", "Spiral"};
        JComboBox cmb = new JComboBox(strStructures);
        return cmb;
    }

//    public ViewComposed getStructure(String strVisualStructure){
//        if(strVisualStructure.equals("Grid"))
//            return new VSGrid();
//        if(strVisualStructure.equals("Circle"))
//            return new VSCircle();
//        if(strVisualStructure.equals("Concentric Rings"))
//            return new VSRings();
//        if(strVisualStructure.equals("Spiral"))
//            return new VSSpiral();
//    }
}
